<?php
class ControllerPaymentCheque extends Controller {
    public function index() {
        $this->language->load('payment/cheque');

        $this->data['text_instruction'] = $this->language->get('text_instruction');
        $this->data['text_payable'] = $this->language->get('text_payable');
        $this->data['text_address'] = $this->language->get('text_address');
        $this->data['text_payment'] = $this->language->get('text_payment');

        $this->data['button_confirm'] = $this->language->get('button_confirm');

        $this->data['payable'] = $this->setting->get('cheque_payable');
        $this->data['address'] = nl2br($this->setting->get('config_address'));

        $this->data['continue'] = $this->url->link('checkout/success');

        $this->template = 'payment/cheque.tpl';

        return $this->render(); 
    }

    public function confirm() {
        $this->app->model('checkout/voucher', true, true);
        $this->app->model('account/customer', true, true);
        $this->app->model('localisation/language', true, true);

        $this->app->model('checkout/order', true, true);

        $comment  = $this->language->get('text_payable') . "\n";
        $comment .= $this->setting->get('cheque_payable') . "\n\n";
        $comment .= $this->language->get('text_address') . "\n";
        $comment .= $this->setting->get('config_address') . "\n\n";
        $comment .= $this->language->get('text_payment') . "\n";

        $this->model_checkout_order->confirm($this->session->data['order_id'], $this->setting->get('cheque_order_status_id'), $comment, true);
    }
}
?>
